#ifndef COMMAND_DISCUSS_COMMAND_H_
#define COMMAND_DISCUSS_COMMAND_H_

#include "command.h"

#ifdef _WIN32
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif

#pragma pack(1)
namespace Cmd
{
        enum { //CMD_DISCUSS
                SCMD_DISCUSS_NULL                       = 0x0000,
                SCMD_DISCUSS_CREATE_REQ                 = 0x0001,       // 创建请求
                SCMD_DISCUSS_CREATE_RES                 = 0x0002,       // 创建返回
                SCMD_DISCUSS_INVITE_REQ                 = 0x0003,       // 邀请请求
                SCMD_DISCUSS_INVITE_RES                 = 0x0004,       // 邀请返回
                SCMD_DISCUSS_INVITE_NOTIFY_HIM          = 0x0005,       // 邀请通知被邀请人
                SCMD_DISCUSS_ADD_USER_NOTIFY_ALL        = 0x0006,       // 增加用户通知讨论组成员
                SCMD_DISCUSS_QUIT_REQ                   = 0x0007,       // 退出请求
                SCMD_DISCUSS_DEL_USER_NOTIFY            = 0x0008,       // 删除用户通知讨论组成员
                SCMD_DISCUSS_MODIFY_TOPIC_REQ           = 0x0009,       // 修改标题请求
                SCMD_DISCUSS_MODIFY_TOPIC_RES           = 0x000A,       // 修改标题返回
                SCMD_DISCUSS_MODIFY_TOPIC_NOTIFY        = 0x000B,       // 修改标题通知讨论组成员
                SCMD_DISCUSS_LIST_REQ                   = 0x000C,       // 讨论组列表请求
                SCMD_DISCUSS_LIST_RES                   = 0x000D,       // 讨论组列表返回
                SCMD_DISCUSS_BASE_INFO_REQ              = 0x000E,       // 讨论组基本信息请求
                SCMD_DISCUSS_BASE_INFO_RES              = 0x000F,       // 讨论组基本信息返回
                SCMD_DISCUSS_MEMBER_LIST_REQ            = 0x0010,       // 讨论组成员列表请求
                SCMD_DISCUSS_MEMBER_LIST_RES            = 0x0011,       // 讨论组成员列表返回
                SCMD_DISCUSS_MEMBER_STATE_NOTIFY        = 0x0012,       // 成员状态改变通知讨论组成员
                SCMD_DISCUSS_CHAT_MSG_OLD               = 0x0013,       // 讨论组内聊天消息
                SCMD_DISCUSS_OFFLINE_MSG_REQ            = 0x0014,       // 离线消息请求(最近的20条)
                SCMD_DISCUSS_QUERY_MEMBER_LIST_REQ      = 0x0015,       // 查询是否存在这样一个讨论组
                SCMD_DISCUSS_QUERY_MEMBER_LIST_RES      = 0x0016,       // 返回是否存在这样一个讨论组
                SCMD_DISCUSS_MEMBER_NICK_NOTIFY         = 0x0017,       // 通知成员的昵称改变
                SCMD_DISCUSS_DEFAULT_MEMBER_LIMIT_REQ   = 0x0018,       // 查询讨论组成员上限
                SCMD_DISCUSS_DEFAULT_MEMBER_LIMIT_RES   = 0x0019,       // 返回讨论组成员上限
                SCMD_DISCUSS_QUERY_MEMBER_NUM_REQ       = 0x001A,
                SCMD_DISCUSS_QUERY_MEMBER_NUM_RES       = 0x001B,
                SCMD_DISCUSS_QUERY_LAST_CHAT_TIME_REQ   = 0x001C,       // 请求最后聊天的时间
                SCMD_DISCUSS_QUERY_LAST_CHAT_TIME_RES   = 0x001D,       // 返回最后聊天的时间
                SCMD_DISCUSS_REMOVE_USER_REQ            = 0x001E,       // 创建者踢人
                SCMD_DISCUSS_REMOVE_USER_RES            = 0x001F,       // 创建者踢人返回
                SCMD_DISCUSS_REMOVE_USER_NOTIFY_HIM     = 0x0020,       // 被踢后接到告知
                SCMD_DISCUSS_MEMBER_LIMIT_REQ           = 0x0021,       // 询问该讨论组人数上限
                SCMD_DISCUSS_MEMBER_LIMIT_RES           = 0x0022,       // 返回该讨论组人数上限
                SCMD_DISCUSS_RECYCLE_NOTIFY             = 0x0023,       // 回收通知
                SCMD_DISCUSS_CHAT_MSG                   = 0x0024,
                SCMD_DISCUSS_CHAT_MSG_ACK               = 0x0025,
                SCMD_DISCUSS_INFO_FOR_APP_REQ           = 0x0026,       // 移动端请求讨论组信息
                SCMD_DISCUSS_INFO_FOR_APP_RES           = 0x0027,       // 移动端请求讨论组信息返回
        };
        struct stDiscussCreateReq:
                t_NullCmd
        {
                stDiscussCreateReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_CREATE_REQ)
                {
                        bzero(topic_, sizeof(topic_));
                }
                char topic_[MAX_DISCUSS_TOPIC_LEN + 1];  // 讨论组标题
        };
        struct stDiscussCreateRes:
                t_NullCmd
        {
                stDiscussCreateRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_CREATE_RES)
                {
                        discuss_id_ = 0;
                        bzero(topic_, sizeof(topic_));
                        ret_code_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                char topic_[MAX_DISCUSS_TOPIC_LEN+1];  // 讨论组标题
                BYTE ret_code_; //0-fail 1-success
        };
        struct stDiscussInviteReq:
                t_NullCmd
        {
                stDiscussInviteReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_INVITE_REQ)
                {
                        discuss_id_ = 0;
                        user_num_   = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                WORD  user_num_;  // 用户个数
                DWORD user_list_[0];  // 用户ID列表
                DWORD getSize() {
                        return sizeof(*this)+user_num_*sizeof(user_list_[0]);
                }
        };
        struct stDiscussInviteRes:
                t_NullCmd
        {
                stDiscussInviteRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_INVITE_RES)
                {
                        discuss_id_ = 0;
                        user_num_   = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                WORD  user_num_; // 信息个数
                struct stResult {
                        DWORD user_id_;  // 用户ID
                        BYTE ret_code_; //0-fail, 1-success
                } user_list_[0];  // 返回信息列表
                DWORD getSize() {
                        return sizeof(*this) + user_num_*sizeof(user_list_[0]);
                }
        };
        struct stDiscussInviteNotifyHim:
                t_NullCmd
        {
                stDiscussInviteNotifyHim():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_INVITE_NOTIFY_HIM)
                {
                        discuss_id_ = 0;
                        creator_id_ = 0;
                        create_time_ = 0;
                        bzero(creator_name_, sizeof(creator_name_));
                        bzero(creator_nick_, sizeof(creator_nick_));
                        bzero(topic_, sizeof(topic_));
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD creator_id_;  // 创建者ID
                DWORD create_time_;  // 创建时间
                char creator_name_[MAX_ACCOUNT_SIZE+1];  // 创建者账号
                char creator_nick_[MAX_NAME_SIZE+1];  // 创建者昵称
                char topic_[MAX_DISCUSS_TOPIC_LEN + 1];  // 讨论组标题
        };
        struct stDiscussAddUserNotifyAll:
                t_NullCmd
        {
                stDiscussAddUserNotifyAll():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_ADD_USER_NOTIFY_ALL)
                {
                        discuss_id_ = 0;
                        invitor_id_ = 0;
                        user_num_   = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD invitor_id_;
                WORD  user_num_; // 用户个数
                struct stUserInfo {
                        DWORD user_id_;  // 用户ID
                        char user_name_[MAX_ACCOUNT_SIZE+1];  // 用户账号
                        char nick_name_[MAX_NAME_SIZE+1];  // 用户昵称
                } user_list_[0];  // 用户信息列表
                DWORD getSize() {
                        return sizeof(*this)+user_num_*sizeof(user_list_[0]);
                }
        };
        struct stDiscussQuitReq:
                t_NullCmd
        {
                stDiscussQuitReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUIT_REQ)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussDelUserNotify:
                t_NullCmd
        {
                stDiscussDelUserNotify():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_DEL_USER_NOTIFY)
                {
                        discuss_id_ = 0;
                        user_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD user_id_;  // 用户ID
        };
        struct stDiscussModifyTopicReq:
                t_NullCmd
        {
                stDiscussModifyTopicReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MODIFY_TOPIC_REQ)
                {
                        discuss_id_ = 0;
                        bzero(topic_, sizeof(topic_));
                }
                DWORD discuss_id_;  // 讨论组ID
                char topic_[MAX_DISCUSS_TOPIC_LEN + 1];  // 讨论组标题
        };
        struct stDiscussModifyTopicRes:
                t_NullCmd
        {
                stDiscussModifyTopicRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MODIFY_TOPIC_RES)
                {
                        discuss_id_ = 0;
                        bzero(topic_, sizeof(topic_));
                        ret_code_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                char topic_[MAX_DISCUSS_TOPIC_LEN + 1];  // 讨论组标题
                BYTE ret_code_; //0-fail 1-success
        };
        struct stDiscussModifyTopicNotify:
                t_NullCmd
        {
                stDiscussModifyTopicNotify():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MODIFY_TOPIC_NOTIFY)
                {
                        discuss_id_ = 0;
                        modify_user_id_ = 0;
                        bzero(topic_, sizeof(topic_));
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD modify_user_id_;  // 修改用户ID
                char topic_[MAX_DISCUSS_TOPIC_LEN + 1];  // 讨论组标题
        };
        struct stDiscussListReq:
                t_NullCmd
        {
                stDiscussListReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_LIST_REQ)
                {
                }
        };
        struct stDiscussListRes:
                t_NullCmd
        {
                stDiscussListRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_LIST_RES)
                {
                        num_ = 0;
                }
                WORD num_;  // ID个数
                DWORD list_[0];  //ID列表
                DWORD getSize() {
                        return sizeof(*this) + num_*sizeof(list_[0]);
                }
        };
        struct stDiscussBaseInfoReq:
                t_NullCmd
        {
                stDiscussBaseInfoReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_BASE_INFO_REQ)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussBaseInfoRes:
                t_NullCmd
        {
                stDiscussBaseInfoRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_BASE_INFO_RES)
                {
                        discuss_id_ = 0;
                        bzero(topic_, sizeof(topic_));
                        creator_id_ = 0;
                        bzero(creator_account_, sizeof(creator_account_));
                        bzero(creator_nickname_, sizeof(creator_nickname_));
                        offline_msg_num_  = 0;
                        create_time_= 0;
                        last_active_time_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                char topic_[MAX_DISCUSS_TOPIC_LEN + 1];  // 讨论组标题
                DWORD creator_id_;  // 创建者ID
                char creator_account_[MAX_ACCOUNT_SIZE+1];  // 创建者账号
                char creator_nickname_[MAX_NAME_SIZE+1];  // 创建者昵称
                WORD offline_msg_num_;  // 离线消息个数
                DWORD create_time_;  // 创建时间
                DWORD last_active_time_;  // 最近活跃时间
        };
        struct stDiscussMemberListReq:
                t_NullCmd
        {
                stDiscussMemberListReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MEMBER_LIST_REQ)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussMemberListRes:
                t_NullCmd
        {
                stDiscussMemberListRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MEMBER_LIST_RES)
                {
                        discuss_id_ = 0;
                        num_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                WORD num_;  // 成员信息个数
                struct stMemberInfo {
                        DWORD userid;  // 用户ID
                        char username[MAX_ACCOUNT_SIZE+1];  // 用户账号
                        char nickname[MAX_NAME_SIZE+1];  // 昵称
                        BYTE state;  // 状态
                } list_[0];  // 成员信息列表
                DWORD getSize() {
                        return sizeof(*this) + num_*sizeof(list_[0]);
                }
        };
        struct stDiscussMemberStateNotify:
                t_NullCmd
        {
                stDiscussMemberStateNotify():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MEMBER_STATE_NOTIFY)
                {
                        discuss_id_ = 0;
                        user_id_ = 0;
                        state_ = USER_STATE_OFFLINE;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD user_id_;  // 用户ID
                BYTE state_;  // 状态
        };
        struct stDiscussChatMsgOld:
                t_NullCmd
        {
                stDiscussChatMsgOld():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_CHAT_MSG_OLD)
                {
                        discuss_id_ = 0;
                        sender_ = 0;
                        msg_type_ = eChatMsgType_text;
                        msg_len_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD sender_;  // 发送者ID
                BYTE msg_type_; //eChatMsgType
                WORD msg_len_;  // 消息长度
                char chat_msg_[0];  // 消息体
                DWORD getSize() {
                        return sizeof(*this) + msg_len_*sizeof(chat_msg_[0]);
                }
        };
        struct stDiscussOfflineMsgReq:
                t_NullCmd
        {
                stDiscussOfflineMsgReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_OFFLINE_MSG_REQ)
                {
                        discuss_id_ = 0;
                        num_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                WORD num_; //req num
        };
        struct stDiscussQueryMemberListReq:
                t_NullCmd
        {
                stDiscussQueryMemberListReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUERY_MEMBER_LIST_REQ)
                {
                        num_ = 0;
                }
                WORD num_;  // ID个数
                DWORD member_list_[0];  // 成员id列表
                DWORD getSize()
                {
                        return sizeof(*this) + num_*sizeof(member_list_[0]);
                }
        };
        struct stDiscussQueryMemberListRes:
                t_NullCmd
        {
                stDiscussQueryMemberListRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUERY_MEMBER_LIST_RES)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID //0-不匹配 1-匹配的讨论组ID
        };
        struct stDiscussMemberNickNotify:
                t_NullCmd
        {
                stDiscussMemberNickNotify():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MEMBER_NICK_NOTIFY)
                {
                        discuss_id_ = 0;
                        user_id_ = 0;
                        bzero(nickname_, sizeof(nickname_));
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD user_id_;  // 用户ID
                char nickname_[MAX_NAME_SIZE+1];  // 用户昵称
        };
        struct stDiscussDefaultMemberLimitReq:
                t_NullCmd
        {
                stDiscussDefaultMemberLimitReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_DEFAULT_MEMBER_LIMIT_REQ)
                {
                }
        };
        struct stDiscussDefaultMemberLimitRes:
                t_NullCmd
        {
                stDiscussDefaultMemberLimitRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_DEFAULT_MEMBER_LIMIT_RES)
                {
                        default_limit_ = 50;
                }
                WORD default_limit_;  // 默认限制个数
        };
        struct stDiscussQueryMemberNumReq:
                t_NullCmd
        {
                stDiscussQueryMemberNumReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUERY_MEMBER_NUM_REQ)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussQueryMemberNumRes:
                t_NullCmd
        {
                stDiscussQueryMemberNumRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUERY_MEMBER_NUM_RES)
                {
                        discuss_id_ = 0;
                        member_num_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                WORD  member_num_;  // 成员个数
        };
        struct stDiscussQueryLastChatTimeReq:
                t_NullCmd
        {
                stDiscussQueryLastChatTimeReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUERY_LAST_CHAT_TIME_REQ)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussQueryLastChatTimeRes:
                t_NullCmd
        {
                stDiscussQueryLastChatTimeRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_QUERY_LAST_CHAT_TIME_RES)
                {
                        discuss_id_ = 0;
                        time_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD time_;  // 时间
        };
        struct stDiscussRemoveUserReq:
                t_NullCmd
        {
                stDiscussRemoveUserReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_REMOVE_USER_REQ)
                {
                        discuss_id_ = 0;
                        user_id_    = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD user_id_;  // 用户ID
        };
        struct stDiscussRemoveUserRes:
                t_NullCmd
        {
                stDiscussRemoveUserRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_REMOVE_USER_RES)
                {
                        discuss_id_ = 0;
                        user_id_    = 0;
                        ret_code_   = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD user_id_;  // 用户ID
                BYTE  ret_code_; //0-fail, 1-success
        };
        struct stDiscussRemoveUserNotifyHim:
                t_NullCmd
        {
                stDiscussRemoveUserNotifyHim():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_REMOVE_USER_NOTIFY_HIM)
                {
                        discuss_id_ = 0;
                        operator_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD operator_id_;  // 操作者ID
        };
        struct stDiscussMemberLimitReq:
                t_NullCmd
        {
                stDiscussMemberLimitReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MEMBER_LIMIT_REQ)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussMemberLimitRes:
                t_NullCmd
        {
                stDiscussMemberLimitRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_MEMBER_LIMIT_RES)
                {
                        discuss_id_ = 0;
                        user_limit_ = 50;
                }
                DWORD discuss_id_;  // 讨论组ID
                WORD  user_limit_;  // 用户限制
        };
        struct stDiscussRecycleNotify:
                t_NullCmd
        {
                stDiscussRecycleNotify():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_RECYCLE_NOTIFY)
                {
                        discuss_id_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
        };
        struct stDiscussChatMsg:
                t_NullCmd
        {
                stDiscussChatMsg():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_CHAT_MSG)
                {
                        discuss_id_ = 0;
                        sender_id_ = 0;
                        msg_id_ = 0;
                        msg_type_ = eChatMsgType_text;
                        msg_len_ = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD sender_id_;  // 发送者ID
                DWORD msg_id_;  // 消息ID
                BYTE msg_type_; //eChatMsgType
                WORD msg_len_;  // 文件长度
                char msg_data_[0];  // 消息体
                DWORD getSize() {
                        return sizeof(*this) + msg_len_*sizeof(msg_data_[0]);
                }
        };
        struct stDiscussChatMsgAck:
                t_NullCmd
        {
                stDiscussChatMsgAck():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_CHAT_MSG_ACK)
                {
                        discuss_id_ = 0;
                        msg_id_     = 0;
                }
                DWORD discuss_id_;  // 讨论组ID
                DWORD msg_id_;  // 消息ID
        };

        struct stDiscussInfoForAppReq:
                t_NullCmd
        {
                stDiscussInfoForAppReq():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_INFO_FOR_APP_REQ)
                {
                        discuss_id_ = 0;
                }
                uint32_t discuss_id_;  // 讨论组ID
        };

        struct stDiscussInfoForAppRes:
                t_NullCmd
        {
                stDiscussInfoForAppRes():
                        t_NullCmd(CMD_DISCUSS, SCMD_DISCUSS_INFO_FOR_APP_RES)
                {
                        discuss_id_ = 0;
                        info_len_ = 0;
                }
                uint32_t size() {
                        return sizeof(*this)+info_len_*sizeof(info_data_[0]);
                }
                uint32_t discuss_id_;  // 讨论组ID
                uint16_t info_len_;  // 信息长度
                char info_data_[0]; //json
                //FIELDS:
                //nm    - name 
                //un    - user num
                //lt    - last chat time
        };

};//namespace Cmd
#pragma pack()

#ifdef _WIN32
#pragma warning( pop )
#endif

#endif //COMMAND_DISCUSS_COMMAND_H_
